package utils

import (
	"strings"
	"time"

	"github.com/comfygpt-backend-go/common/database"
	"github.com/google/uuid"
)

// uuid库创建随机 uuid
func GengerateUUID() string {
	return uuid.New().String()
}

func GetNowTime() time.Time {
	return time.Now()
}

// 将字符串数组转换为字符串
func ArrayToString(arr []string) string {
	return strings.Join(arr, ",")
}

// 将字符串转换为字符串数组
func StringToArray(str string) []string {
	return strings.Split(str, ",")
}

// sql 分页查询参数转换
func PageParam(page, size int) (offset, limit int) {
	offset = (page - 1) * size
	limit = size
	return
}

var minioAuthInstance *database.MinioAuth

// 初始化minio认证结构体
func InitMinioAuth(access, secret, endpoint, bucket string, useSSL bool) *database.MinioAuth {
	return &database.MinioAuth{
		AccessKey: access,
		SecretKey: secret,
		Endpoint:  endpoint,
		Bucket:    bucket,
		UseSSL:    useSSL,
	}
}

// 获取minio 认证结构体
func GetMinioAuth() *database.MinioAuth {
	return minioAuthInstance
}
